import { configToSearch, toSearchHandle } from '@/views/datacenter/business/utils/index'

const tableConfig = {
	stripe: true,
	border: true,
	maxHeight: '80vh',
	columns: [
		{ label: '养老机构', prop: 'organizationName' },
		{ label: '姓名', prop: 'personName' },
		{ label: '身份证号', prop: 'idCard', plusXing: '2,2' },
		{ label: '打卡人', prop: 'punchName' },
		{
			label: '打卡方式',
			prop: 'punchType',
			propName: 'punchTypeLabel',
			code: 'PUNCH_TYPE',
			api: 'getDictItemList',
			type: 'remoteSelect',
		},
		{ label: '打卡时间', prop: 'punchTime' },
		{ label: '打卡地点', prop: 'punchPlace' },
		{ label: '打卡照片', prop: 'punchImg', custome: 'img' },
		{
			label: '是否可信',
			prop: 'isBelievable',
			custome: 'tag',
			dicData: [
				{ label: '否', value: 0, type: 'danger' },
				{ label: '是', value: 1, type: 'success' },
			],
		},
		{
			label: '操作',
			prop: 'menu',
			width: 300,
			fixed: 'right',
		},
	],
}

export const detailConfig = {
	inline: false,
	showBtn: false,
	labelPosition: 'top',
	column: [
		{
			label: '养老机构',
			prop: 'organizationName',
			type: 'text',
			maxlength: '50',
			showWordLimit: true,
			span: 8,
		},
		{
			label: '姓名',
			prop: 'personName',
			type: 'text',
			maxlength: '20',
			showWordLimit: true,
			span: 8,
		},
		{
			label: '身份证号',
			prop: 'idCard',
			type: 'text',
			maxlength: '18',
			showWordLimit: true,
			span: 8,
		},
		{
			label: '能力等级',
			prop: 'abilityLevel',
			propName: 'abilityLevelLabel',
			code: 'ACCESS_LEVEL_COUNTRY',
			type: 'remoteSelect',
			api: 'getDictItemList',
			span: 8,
		},
		{
			label: '打卡方式',
			prop: 'punchType',
			propName: 'punchTypeLabel',
			code: 'PUNCH_TYPE',
			api: 'getDictItemList',
			type: 'remoteSelect',
			span: 8,
		},
		{
			label: '打卡人',
			prop: 'punchName',
			type: 'text',
			maxlength: '20',
			showWordLimit: true,
			span: 8,
		},
		{
			label: '打卡地点',
			prop: 'punchPlace',
			type: 'text',
			maxlength: '50',
			showWordLimit: true,
			span: 8,
		},
		{
			label: '打卡时间',
			prop: 'punchTime',
			type: 'datetime',
			format: 'YYYY年MM月DD HH:mm:ss',
			valueFormat: 'YYYY-MM-DD HH:mm:ss',
			span: 8,
		},
		{
			label: '打卡照片',
			prop: 'punchImg',
			type: 'upload',
			labelPosition: 'top',
			showFileList: false,
			limit: 1,
			multiple: false,
			custome: 'img',
			span: 24,
		},
	],
}
const moreSearchConfig: any = {
	inline: true,
	showBtn: false,
	labelPosition: 'left',
	column: [...configToSearch(detailConfig.column)],
}
export const detailEmployeeConfig = {
	inline: false,
	showBtn: false,
	labelPosition: 'left',
	column: [
		{ label: '养老机构', prop: 'organizationName', span: 8 },
		{ label: '姓名', prop: 'personName', span: 8 },
		{ label: '身份证号', prop: 'idCard', span: 8 },

		{
			label: '打卡方式',
			prop: 'punchType',
			propName: 'punchTypeLabel',
			code: 'PUNCH_TYPE',
			api: 'getDictItemList',
			type: 'remoteSelect',
			span: 8,
		},
		{ label: '打卡图片', prop: 'punchImg', span: 8, custome: 'img' },
		{ label: '打卡人', prop: 'punchName', span: 8 },
		{ label: '打卡地点', prop: 'punchPlace', span: 8 },
		{
			label: '打卡时间',
			prop: 'punchTime',
			type: 'datetime',
			format: 'YYYY年MM月DD HH:mm:ss',
			valueFormat: 'YYYY-MM-DD HH:mm:ss',
			span: 8,
		},
	],
}
export const importConfig = {
	tabSteps: [
		{
			label: '下载模板',
			download: '下载模板',
			active: 1,
			rules: [
				{
					label: '下载最新导入模板。共1个：',
					children: [
						{
							label: '《打卡记录》',
							link: true,
							url: 'view_dpOrgPunchRecord_downloadTemplate',
						},
					],
				},
			],
		},
		{
			label: '导入信息',
			description: '',
			uploadTip: '打卡记录表',
			active: 2,
			url: 'view_dpOrgPunchRecord_import',
			code: 3024,
			rules: [
				{
					label: '导入规则说明:',
					children: [
						{
							label: '(1)导入模式为“覆盖导入”，待导入的信息会覆盖平台已存在的',
						},
					],
				},
			],
		},
	],
	dataType: 94,
}
export const baseConfig = {
	pageName: '机构打卡管理',
	dictcodes: ['PUNCH_TYPE', 'ACCESS_LEVEL_COUNTRY'],
	rowKey: 'id',
	tipLabel: 'personName',
	exportMqTopic: '/ning/export/',
	paramsObj: {
		code: 3024,
	},
	api: {
		moreSearch: 'view_dpOrgPunchRecord_search',
		index: 'view_dpOrgPunchRecord_page',
		delete: 'view_dpOrgPunchRecord_del',
		edit: 'view_dpOrgPunchRecord_edit',
		import: 'view_dpOrgPunchRecord_import',
		export: 'view_dpOrgPunchRecord_export',
	},
	auth: {
		index: 'view_dpOrgPunchRecord_page',
		delete: 'view_dpOrgPunchRecord_del',
		edit: 'view_dpOrgPunchRecord_edit',
		// import: 'view_dpOrgPunchRecord_import',
		// export: 'view_dpOrgPunchRecord_export',
		mulitSet: 'mulitSet',
	},
	menuBtn: [
		{
			icon: 'detail',
			label: '查看',
			type: 'primary',
			operate: 'detail',
			auth: 'view_dpOrgPunchRecord_page',
			text: true,
			show: true,
		},
		{
			icon: 'edit',
			label: '编辑',
			type: 'primary',
			operate: 'edit',
			auth: 'view_dpOrgPunchRecord_edit',
			text: true,
			show: true,
		},
		{
			icon: 'delete',
			label: '删除',
			type: 'danger',
			operate: 'delete',
			auth: 'view_dpOrgPunchRecord_del',
			text: true,
			show: true,
		},
	],
	dialogConfig: {
		width: '80%',
	},
	moreSearchConfig,
	searchConfig: {
		inline: true,
		showBtn: true,
		labelPosition: 'left',
		column: [
			{ label: '养老机构', prop: 'organizationName', span: 8 },
			{ label: '姓名', prop: 'personName', span: 8 },
			{ label: '身份证号', prop: 'idCard', span: 8 },
			{
				label: '打卡方式',
				prop: 'punchType',
				propName: 'punchTypeLabel',
				type: 'remoteSelect',
				code: 'PUNCH_TYPE',
				api: 'getDictItemList',
				filterKey: 'value',
				multiple: false,
				span: 8,
			},
		],
	},
	importConfig,
	tableConfig,
	detailConfig,
	formConfig: {
		...detailConfig,
		showBtn: true,
	},
	beforeOnLoadFormate: async (params) => {
		params = toSearchHandle(moreSearchConfig, {}, params)
		return Promise.resolve({
			...params,
		})
	},
}
